<template>
  <div class="container-header head-form" slot="header">
    <Form class="search">
      <Row>
        <Col span="8">
          <FormItem label="盘存编号">
            <Input v-model.trim="list.form.sn" placeholder="门店名称" @on-enter="onSearchBtnClick"/>
          </FormItem>
          <FormItem label="盘存时间">
            <DatePicker v-model="timeRange" type="daterange"></DatePicker>
          </FormItem>
        </Col>
        <Col span="8">
          <FormItem label="经销商名称">
            <Input v-model.trim="list.form.distributorName" placeholder="经销商名称" @on-enter="onSearchBtnClick"/>
          </FormItem>
          <FormItem label="操作人">
            <Input v-model.trim="list.form.operatorName" placeholder="操作人" @on-enter="onSearchBtnClick"/>
          </FormItem>
        </Col>
        <Col span="6">
          <FormItem label="商品名">
            <Input v-model.trim="list.form.goodName" placeholder="商品名" @on-enter="onSearchBtnClick"/>
          </FormItem>
        </Col>
        <Col class-name="search" span="2">
          <Button class="btn-search large" type="primary" icon="ios-search" @click="onSearchBtnClick"></Button>
        </Col>
      </Row>
    </Form>
  </div>
</template>

<script>
  import AreaSelect from '@/components/AreaSelect';
  import SelectList from '@/components/SelectList';
  import { formatDate } from '@/util';

  export default {
    props: {
      list: {
        type: Object,
        default: ''
      }
    },
    data() {
      return {
        currValue: [],
      }
    },
    computed: {
      timeRange: {
        get() {
          return [this.list.form.startDate, this.list.form.endDate]
        },
        set(val) {
          const [s, e] = val
          this.list.form.startDate = s ? formatDate(s) + ' 00:00:00' : s
          this.list.form.endDate = e ? formatDate(e) + ' 23:59:59' : e
        }
      }
    },
    components: {
      AreaSelect,
      SelectList,
    },
    mounted() {
    },
    methods: {
      onSearchBtnClick() {
        this.$emit('onSearchBtnClick')
      },
      onAddBtnClick() {
        this.$emit('onAddBtnClick')
      },
    },
    watch: {
    }
  }
</script>
